package controller;

import service.AtmService;
import util.MySpring;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class DoDeposit extends HttpServlet {
    AtmService atmService = MySpring.getBean("service.AtmService");

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("DoDeposit.service");
        String name10 = req.getParameter("name8");
        String depositBalance = req.getParameter("depositBalance1");
        atmService.deposit(name10, Float.valueOf(depositBalance));
        resp.setCharacterEncoding("UTF-8");//设置 服务器向浏览器发送响应信息的字符集
        PrintWriter out = resp.getWriter();
        out.write("<html>");
        out.write("<head>");
        out.write("<meta charset=\"UTF-8\">");//告诉浏览器 按照这种字符集解析
        out.write("</head>");
        out.write("<body>");
        out.write("****************************<br>");
        out.write("欢迎"+name10+"进入ATM系统<br>");
        out.write("****************************<br>");
        out.write("请输入操作选项<br>");
        out.write("<a href=\"inquiry?name5="+name10+"\">查询</a><br>");//请求操作资源
        out.write("<a href=\"deposit?name7="+name10+"\">存款</a><br>");//请求操作资源
        out.write("<a href=\"\">取款</a><br>");
        out.write("<a href=\"\">转账</a><br>");
        out.write("</body>");
        out.write("</html>");
        out.flush();
    }
}